using UnityEngine;
using System.Collections;

public enum Perspectives {SIDE, TOP, ISO};

public class CameraSimpleFollow : MonoBehaviour 
{
	
	public Perspectives perspective = Perspectives.TOP;
	
	public float cameraDistance = 5.0f;
	public float cameraHeight = 14.0f;
	//public string targetName = "Player";
	
	//Transform target = null;
	Vector3 cameraOffset;
	Quaternion rotation;
	
	public GameObject targetObject = null;
	
	
	
	void Start () 
	{				
		if(perspective == Perspectives.SIDE)
		{			
			cameraOffset = new Vector3(0, 0, -1);
			rotation = Quaternion.Euler(0, 0, 0);
		}
		else if(perspective == Perspectives.TOP)		
		{
			cameraOffset = new Vector3(0, 1, 0);
			rotation = Quaternion.Euler(90, 0, 0);
		}
		else if(perspective == Perspectives.ISO)
		{
			cameraOffset = new Vector3(0, 1, 0);
			rotation = Quaternion.Euler(60, 0, 0);
		}
		// set new rotation
		transform.rotation=rotation;
		//target = GameObject.Find(targetName).transform;
	}

	void Update ()
	{
		if(!targetObject)
			return;
		
		// set new position
		transform.position = targetObject.transform.position + cameraHeight * cameraOffset;
		transform.position = new Vector3 (transform.position.x, transform.position.y, transform.position.z - cameraDistance);
		
		
	}
}
